<template>
    登录页
    <div>
        账号： <input type="text" v-model="account" placeholder="请输入你的账号">
    </div>
    <div>
        <!-- 密码： <input type="password" placeholder="请输入你的密码"> -->
        密码： <input type="text" v-model="password" placeholder="请输入你的密码">
    </div>

    <div>
        <button @click="submit">登录</button>
    </div>
    {{ account }}
    {{ password }}
</template>

<script setup>
import { ref } from "vue";
import {useStore} from 'vuex'
import {useRouter} from 'vue-router'

// store的实例化对象
const store = useStore()
// 路由的实例化对象
const router = useRouter()

const account = ref('')
const password = ref('')



const submit = ()=>{

    console.log('account',account)
    console.log('account.value',account.value);
    if (account.value === 'admin' && password.value === '123456') {
        alert("登录成功")

        store.commit("updateUserInfo", {
            name:'张三',
            gender:'男',
            phone:'13455556666'
        })

        // 跳转用户中心
        router.push({path:'/user'})

    } else {
        alert("账号或密码错误，请重新登录")
    }
}

</script>